package com.wlyuan.index.domain.index.repository.old;

import com.wlyuan.core.domain.valueobj.WaybillId;
import lombok.var;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;

import java.util.List;

public interface WaybillIndexOldRepository extends ElasticsearchRepository<WaybillIndexOld, Long> {

    List<WaybillIndexOld> findByWaybillId(Long waybillId);

    default List<WaybillIndexOld> list(WaybillId waybillId) {
        return this.findByWaybillId(waybillId.getId());
    }

    default Page<WaybillIndexOld> list(int page, int size) {
        var pageable = Pageable.ofSize(size).withPage(page);
        return this.findAll(pageable);
    }
}
